﻿/*----------------------------------------------------------------
// Copyright (C) 2016 通通优品版权所有。
// 命名空间: TongTongMall.MallWeb.Core.Test
// 类名：MallWebService
// 功能描述：N/A
// 
// 创建标识：Roc.Lee(李鹏鹏) 2017/5/3 14:46:40 TEC-ROCLEE Roc.Lee

// 修改标识：
// 修改描述：
// 
//
//----------------------------------------------------------------*/

using Castle.Facilities.Logging;
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.Resolvers.SpecializedResolvers;

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using TongTongMall.Commanding.Messaging;
using TongTongMall.Dependecy;
using TongTongMall.Domain.Services;
using TongTongMall.Logging;


using TongTongMall.Reflection;





namespace TongTongMall.MallWeb.Core.Test
{
    public class MallWebService
    {
        private TongTongMallBootstrapper TongTongMallBootstrapper { get; }

        public MallWebService()
        {
            try
            {
                TongTongMallBootstrapper = new TongTongMallBootstrapper();
                //castle windsor中的日志由log4net实现
                TongTongMallBootstrapper.IocManager.IocContainer
                    .AddFacility<LoggingFacility>(f => f.UseLog4Net().WithConfig("log4net.config"));

                //声明扫描程序集方式
                TongTongMallBootstrapper.IocManager.IocContainer.Register(Component.For(typeof(IAssemblyFinder)).
                    ImplementedBy(typeof(Configuration.FolderAssemblyFinder)).
                    DependsOn(dependency: Dependency.OnValue("folderPath", AppDomain.CurrentDomain.BaseDirectory)).
                    LifestyleSingleton());
                TongTongMallBootstrapper.IocManager.IocContainer.Kernel.Resolver.AddSubResolver(new ArrayResolver(TongTongMallBootstrapper.IocManager.IocContainer.Kernel, true));
                TongTongMallBootstrapper.Initialize();
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
            }
        }
    }
}
